﻿Public Class Frm2Bodegas_RMP

    Public Sub cargarRegistros(ByVal fila As Integer)
        Try
            Dim accion As New BodegaDAO
            'Llenar tabla
            Dim tabla As New DataTable
            tabla = accion.mostrar
            'Comprobar si hay datos
            If Not tabla Is Nothing Then
                'Cargar datos en el grid
                'dgv1.DataSource = tabla
                FormatosGrid.funciones.formatoGrid_Bodegas(DGV1, tabla)
                'Mostrar datos en los controles
                txtID.Text = DGV1.Rows(fila).Cells(0).Value
                txtNombre.Text = DGV1.Rows(fila).Cells(1).Value
                txtTipo.Text = DGV1.Rows(fila).Cells(2).Value
                lblIDTipo.Text = DGV1.Rows(fila).Cells(3).Value
                'Seleccionar toda la fila
                DGV1.Rows(fila).Selected = True
                DGV1.CurrentCell = DGV1.Rows(fila).Cells(1)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK,
                        MessageBoxIcon.Warning)
        End Try
    End Sub
    Private Sub dgv1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DGV1.CurrentCellChanged
        Try
            If Not DGV1.CurrentCell Is Nothing Then
                With DGV1
                    txtID.Text = .Rows(.CurrentCell.RowIndex).Cells(0).Value
                    txtNombre.Text = .Rows(.CurrentCell.RowIndex).Cells(1).Value
                    txtTipo.Text = .Rows(.CurrentCell.RowIndex).Cells(2).Value
                    lblIDTipo.Text = .Rows(.CurrentCell.RowIndex).Cells(3).Value
                End With
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK,
              MessageBoxIcon.Warning)
        End Try
    End Sub

    Private Sub Frm4BodegasMenu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cargarRegistros(0)
    End Sub


    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.Close()
    End Sub
End Class